package org.wjk.handler;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;
import org.wjk.pojo.vo.ResponseRes;
import org.wjk.utils.ResponseUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Component
public class MyAccessDeniedHandler implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
        /*状态码5002  您无访问该资源的权限请联系管理员*/
        ResponseUtils.convertToJson(response, ResponseRes.failure(5002,"您无访问该资源的权限请联系管理员",null));
    }
}
